<?php

class Ext_User_Edit_Email_Adapter
{
    private $_adapter;

    public function __construct($userId)
    {
        if(!isset($this->_adapter))
        {
            $front = Zend_Controller_Front::getInstance();
            $bootstrap = $front->getParam('bootstrap');
            $options = $bootstrap->getApplication()->getOptions();
            
            $classname = "Ext_User_Edit_Email_Adapter_".ucfirst($options['auth']['adapter']['base']);
            if(!class_exists( $classname ))
            {
                require_once 'Ext/User/Edit/Email/Exception.php';
                  throw new Ext_User_Edit_Email_Exception("User edit email adapter '".$classname."' is not exists.");
            }
            
            $this->_adapter = new $classname($userId);
        }
    }
    
    public function edit($email)
    {
        return $this->_adapter->edit($email);
    }
}
